<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<script type="text/javascript">	
$(function() {
	$.jgrid.ajaxOptions.type = 'post';
	$("#product_table").jqGrid(
			{
				url:'cms/product/view',
        		datatype: "json",
        		rownumbers:true,
        		autowidth:true, 
                height: 400,
 				colNames : ['id', '产品名称', '产品小图','产品原价', '产品折扣(会员)','会员折后价格', '人数',
						'活动时间', '最大人数','会员折扣等级','节省价格(原价 * 折扣率)','活动时长(时，天，月)','排序',
						'活动月份','国家','课时','状态','是否返现','是否推荐首页','创建时间','产品描述','操作'],
				colModel : [{
					name : 'id',
					index : 'id',
					width:50,
					hidden:true
				},  {
					name : 'productName',
					index : 'productName',
					width:100
				}, {
					name : 'minPic',
					index : 'minPic',
					width:150,
					formatter:function(cell,options,row){
						return "<img src='"+row.minPic+"' style='width:150px;height:80px;'/>";
					}
				}, {
					name : 'price',
					index : 'price',
					width:80
				}, {
					name : 'discount',
					index : 'discount'
				}, {
					name : 'discountPrice',
					index : 'discountPrice',
					width:100
				}, {
					name : 'number',
					index : 'number',
					width:80
				}, {
					name : 'departureTime',
					index : 'departureTime',
					width:150
				}, {
					name : 'maxNumber',
					index : 'maxNumber',
					width:80
				}, {
					name : 'membershipGrade',
					index : 'membershipGrade',
					width:80
				}, {
					name : 'saveMuchMoney',
					index : 'saveMuchMoney',
					width:160
				}, {
					name : 'activityDuration',
					index : 'activityDuration',
					width:160
				}, {
					name : 'sort',
					index : 'sort',
					width:80
				}, {
					name : 'month',
					index : 'month',
					width:80
				}, {
					name : 'region',
					index : 'region',
					width:80
				}, {
					name : 'classHour',
					index : 'classHour',
					width:80
				}, {
					name : 'stats',
					index : 'stats',
					width:80,
					formatter:function(cell,options,row){
						if(row.stats == 1){
							return "上架";
						}else{
							return "下架";
						}
					}
				}, {
					name : 'cashback',
					index : 'cashback',
					width:80,
					formatter:function(cell,options,row){
						if(row.cashback == 1){
							return "返现";
						}else{
							return "不返现";
						}
					}
				}, {
					name : 'recommend',
					index : 'recommend',
					width:80,
					formatter:function(cell,options,row){
						if(row.cashback == 1){
							return "推荐";
						}else{
							return "不推荐";
						}
					}
				}, {
					name : 'createDate',
					index : 'createDate',
					width:150
				}, {
					name : 'remark',
					index : 'remark',
					width:150,
					formatter:function(cell,options,row){
						if(row.remark.length > 100){
							return row.remark.substring(0,99)+"...";
						}
						return row.remark;
					}
				},{
					name : 'opt',
					index : 'opt',
					width: 50,
					formatter:function(cell,options,row){
						var result = '';
						result = '<a href="#" onclick="modity(\''+row.id+'\')">修改</a>';
						result = result + ' <a href="#" onclick="deleteProduct(\''+row.id+'\')">删除</a>';
						return result;
					}
				}
				],
				rowNum : 10,
				rowList : [ 10, 20, 30 ],
				jsonReader : {
					root : "data",
					id : "id",
					page : "index",
					records : "totalRecord",
					repeatitems : false
				},
				pager : "#pgtoolbar"
			});
});
 

function deleteProduct(id){
	art.dialog({
		title : '删除产品',
		lock : true,
		content : '确认删除产品?',
		width : '200px',
	    cancelVal: '关闭',
	    cancel: true,
		ok : function () {
			$.post("cms/product/delete?id="+id, function(data) {
				if(data.code!="01"){
					$("#product_table").jqGrid("setGridParam", {
						datatype : "json"
					}).trigger("reloadGrid", [ {
						page : 1
					} ]);
				}
			});
		}
	});
}

function modity(id){
	to_page('/cms/product/modify/page?id='+id);
}
</script>
</head>
<body>
		<div class="r_location">
			<i class="r_txtico"></i>微信内容管理&gt;产品配置管理
		</div>
		
		<div class="m-t10">
 <div class="clearfix table_fn">
			<span class="l">产品配置管理数据列表</span> <span class="r"
				style="_margin-top: 5px;"> <a href="#" title="" class="add_ico"  onclick="to_page('/cms/product/add/page');"  id="advertise_add">新增</a>
			</span>
	    </div>
			<table id="product_table">
			</table>
			<div id="pgtoolbar"></div>
		</div>
	 
</body>
</html>